import request from '@/config/axios'
import type {Dayjs} from 'dayjs';

/** ERP 基础资料模具信息 */
export interface BasicMould {
  id: number; // 模具编号
  name?: string; // 模具名字
  code: string; // 编码
  status?: number; // 模具状态
  purchaseUserId: number; // 采购人
  purchaseTime: string | Dayjs; // 采购日期
  purchasePrice: number; // 采购价格
  speedOut?: number; // 出速
  remark: string; // 备注
}

// ERP 基础资料模具 API
export const BasicMouldApi = {
  // 查询ERP 基础资料模具分页
  getBasicMouldPage: async (params: any) => {
    return await request.get({url: `/erp/basic-mould/page`, params})
  },
  getBasicMouldSimpleList: async (params: any) => {
    return await request.get({url: `/erp/basic-mould/simple-list`, params})
  },
  // 查询ERP 基础资料模具详情
  getBasicMould: async (id: number) => {
    return await request.get({url: `/erp/basic-mould/get?id=` + id})
  },

  // 新增ERP 基础资料模具
  createBasicMould: async (data: BasicMould) => {
    return await request.post({url: `/erp/basic-mould/create`, data})
  },

  // 修改ERP 基础资料模具
  updateBasicMould: async (data: BasicMould) => {
    return await request.put({url: `/erp/basic-mould/update`, data})
  },

  // 删除ERP 基础资料模具
  deleteBasicMould: async (id: number) => {
    return await request.delete({url: `/erp/basic-mould/delete?id=` + id})
  },

  /** 批量删除ERP 基础资料模具 */
  deleteBasicMouldList: async (ids: number[]) => {
    return await request.delete({url: `/erp/basic-mould/delete-list?ids=${ids.join(',')}`})
  },

  // 导出ERP 基础资料模具 Excel
  exportBasicMould: async (params) => {
    return await request.download({url: `/erp/basic-mould/export-excel`, params})
  }
}
